package com.mojo.concurrent.threadsafe;

/**
 * 线程实现类
 *
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
public class RunnableImpl implements Runnable {
    private int ticket = 100;

    @Override
    public void run() {
        synchronized (this) {
            while (ticket > 0) {

                //
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "买了第" + ticket + "张票");
                ticket--;
            }
            //}
        }

    }
}
